<template>
  <div class="loading">
    <div class="warp">
      <div class="com__box">
        <div class="login-loading">
          <div class="shape shape-1"></div>
          <div class="shape shape-2"></div>
          <div class="shape shape-3"></div>
          <div class="shape shape-4"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Loading } from "vant";

export default {
  data() {
    return {
      msg: "",
    };
  },
  components: {
    [Loading.name]: Loading,
  },
  created() {
    this.login();
  },
  methods: {
    login() {
      let code = this.$route.query.code;
      let type = process.env.VUE_APP_SYSTEM_ID;
      if (code) {
        if (this.$route.query.state) {
          type = this.$route.query.state;
        }
        let that = this;
        this.$axios
          .get(this.$urls.getToken + `?code=${code}&state=${type}`)
          .then((res) => {
            if (res.code == 200) {
              localStorage.setItem("token", res.result.tokenValue);
              localStorage.setItem("tokenName", res.result.tokenName);
              that.$router.push("/member");
            }
          });
      } else {
        window.location.href =
          "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1d6f991b7360ecfb&redirect_uri=http://ccic-ai.iccec.cn/back/api/wechat/authorization?url=http://ccic-ai.iccec.cn/usercenter/login&state=11&response_type=code&scope=snsapi_userinfo&state=1&forcePopup=true#wechat_redirect";
      }
    },
  },
};
</script>

<style scoped>
.warp {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-loading {
  width: 30px;
  height: 30px;
  margin-left: 10px;
  position: relative;
  transform: rotate(45deg);
}

.shape {
  width: 10px;
  height: 10px;
  position: absolute;
}

.shape-1 {
  background-color: #1875e5;
  left: 0;
  animation: animationShape1 0.5s ease infinite alternate;
}

.shape-2 {
  background-color: #c5523f;
  right: 0;
  animation: animationShape2 0.5s ease infinite alternate;
}

.shape-3 {
  background-color: #499255;
  bottom: 0;
  animation: animationShape3 0.5s ease infinite alternate;
}

.shape-4 {
  background-color: #f2b736;
  right: 0;
  bottom: 0;
  animation: animationShape4 0.5s ease infinite alternate;
}

@keyframes animationShape1 {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(16px, 16px);
  }
}

@keyframes animationShape2 {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(-16px, 16px);
  }
}

@keyframes animationShape3 {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(16px, -16px);
  }
}

@keyframes animationShape4 {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(-16px, -16px);
  }
}
</style>
